<?php

namespace App\Jobs;

use App\Services\NoticeService;
use App\Services\ShopNotice;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ShopNoticeJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $data;

    /**
     * ShopNotice   Job constructor.
     * @param $data
     */
    public function __construct($data)
    {
        $this->data = $data;
    }

    /**
     * 2021/3/18--14:55
     * @author:董宗澳
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @method:handle
     * @effect:对列执行逻辑
     */
    public function handle()
    {
        try {
            $ShopNoticeService = new ShopNotice();
            $data = [
                'user_id' => $this->data['user_id'],
                'title' => $this->data['title'],
                'content' => $this->data['content'],
                'notice_name' => '系统',
                'created_at' => now()->timestamp,
                'updated_at' => now()->timestamp,
                'order_id' => $this->data['order_id']
            ];
            $ShopNoticeService->addNotice($data);
        } catch (\Exception $e) {
            $this->release(5);
        }
    }
}
